package com.yuanchu.marketing.dao;

import com.yuanchu.marketing.entity.YoshopCouponEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 优惠券记录表
 * 
 * @author adan
 * @email 2028038953@gmail.com
 * @date 2023-12-19 20:57:23
 */
@Mapper
public interface YoshopCouponDao extends BaseMapper<YoshopCouponEntity> {
    @Update("update yoshop_coupon set total_num = yoshop_coupon.total_num - 1\n" +
            "                        where coupon_id = #{couponId} and store_id = #{storeId}\n" +
            "and yoshop_coupon.total_num > 0")
    Integer updateCouponNum(@Param("couponId")Integer couponId,
                                   @Param("storeId") Integer storeId);
}
